package raft

import (
	"log"
)

const (
	ERROR = 2
	INFO  = 1
	DEBUG = 0
)

type Message struct {
	PrintLevel int
}

func (m *Message) SetLevel(level int) {
	m.PrintLevel = level
}

func (m *Message) Info(format string, msgs ...any) {
	format = "INFO " + format
	m.Print(INFO, format, msgs...)
}

func (m *Message) Debug(format string, msgs ...any) {
	format = "DEBUG " + format
	m.Print(DEBUG, format, msgs...)
}

func (m *Message) Error(format string, msgs ...any) {
	format = "ERROR " + format
	m.Print(ERROR, format, msgs...)
}

func (m *Message) Print(level int, format string, msgs ...any) {
	if m.PrintLevel <= level {
		log.Printf(format, msgs...)
	}
}

//func (m *Message) Sprintf(format string, msgs ...any) string {
//	return fmt.Sprintf(format, msgs)
//}
